package freespiritsocial.io.user.data.model.bean

import android.os.Parcelable
import freespiritsocial.io.user.R
import freespiritsocial.io.user.base.App
import freespiritsocial.io.user.ext.str
import kotlinx.android.parcel.Parcelize

/**
 * 描述　: 账户信息
 */
@Parcelize
data class UserInfo(
    val areaCode: String? = "",
    var birthday: String? = "",
    var country: String? = "",
    val fansCount: Int? = 0,
    val followers: Int? = 0,//点赞数
    val attentionCount: Int? = 0,//关注数
    val inviterId: String? = "",
    var isRead: Boolean = false,
    val isDelete: Int? = 0,
    val isDisable: Int? = 0,
    val isOtherUserInfo: Int? = 0,
    val likesCount: Int? = 0,
    val loginTime: Int? = 0,
    var name: String? = "",
    val platformName: String? = "",
    val postsCount: Int? = 0,
    val resourceId: String? = "",
    var status: Int? = 0,
    val thirdPartyId: String? = "",
    val thirdPartyType: Int? = 0,
    val updateTime: Int? = 0,
    var userAvatar: String? = "",
    var userEmail: String? = "",
    val userId: String? = "",
    val userMobile: String? = "",
    var userName: String? = "",
    val userSex: Int? = 0
): Parcelable {
    companion object {
        const val genderMale = 1
        const val genderFemale = 2
        const val genderOther = 0
        const val STATUS_ADD = 0
        const val STATUS_DEL = 1
    }

    // 0添加 1删除
    var eventStatus: Int = STATUS_ADD

    val isFollowed get() = status == 1

    fun changeFollowStatus() {
        status = if (isFollowed) 2 else 1
    }

    val notifyIcon get() = App.instance.getDrawable(if (isRead) R.mipmap.icon_notify else R.mipmap.icon_notify_no_unread)

    val followStr
        get() = (if (isFollowed) R.string.following else R.string.follow).str()

    //蕾蕾的套路
    val notifyFollowStr
        get() = (if (!isFollowed) R.string.following else R.string.follow).str()

    override fun equals(other: Any?): Boolean {
        if (other is UserInfo && other.userId == userId) return true
        return super.equals(other)
    }

    override fun hashCode(): Int {
        return userId?.hashCode() ?: 0
    }
}

